package com.briup.cms.service.impl;

import com.briup.cms.bean.Comment;
import com.briup.cms.bean.extend.CommentExtend;
import com.briup.cms.dao.CommentMapper;
import com.briup.cms.service.ICommentService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class CommentServiceImpl implements ICommentService {

    @Resource
    private CommentMapper commentMapper;

    @Override
    public List<Comment> findAll() {

        return commentMapper.selectAll();
    }


    @Override
    public void saveOrUpdate(Comment comment) {

        if (comment.getId()!=null){
            commentMapper.update(comment);
        }
        else{

            commentMapper.insert(comment);
        }
    }

    @Override
    public void deleteById(long id) {

        commentMapper.deleteById(id);
    }

    @Override
    public List<CommentExtend> selectAllWithArticle() {
        return commentMapper.selectAllWithUser();
    }

    @Override
    public List<CommentExtend> selectAllWithUser() {
        return commentMapper.selectAllWithUser();
    }
}
